home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / DJINC106.ARJ / AOUT.H < prev    next >
C/C++ Source or Header  |  1992-03-09  |  8KB  |  260 lines

  1. /* This file may have been modified by DJ Delorie (Jan 1991).  If so,
  2. ** these modifications are Coyright (C) 1991 DJ Delorie, 24 Kirsten Ave,
  3. ** Rochester NH, 03867-2954, USA.
  4. */
  5.  
  6. #ifndef __A_OUT_GNU_H__
  7. #define __A_OUT_GNU_H__
  8.  
  9. #define __GNU_EXEC_MACROS__
  10.  
  11. #ifndef __STRUCT_EXEC_OVERRIDE__
  12.  
  13. struct exec
  14. {
  15.   unsigned long a_info;         /* Use macros N_MAGIC, etc for access */
  16.   unsigned a_text;              /* length of text, in bytes */
  17.   unsigned a_data;              /* length of data, in bytes */
  18.   unsigned a_bss;               /* length of uninitialized data area for file, in bytes */
  19.   unsigned a_syms;              /* length of symbol table data in file, in bytes */
  20.   unsigned a_entry;             /* start address */
  21.   unsigned a_trsize;            /* length of relocation info for text, in bytes */
  22.   unsigned a_drsize;            /* length of relocation info for data, in bytes */
  23. };
  24.  
  25. #endif /* __STRUCT_EXEC_OVERRIDE__ */
  26.  
  27. /* these go in the N_MACHTYPE field */
  28. enum machine_type {
  29. #if defined (M_OLDSUN2)
  30.   M__OLDSUN2 = M_OLDSUN2,
  31. #else
  32.   M_OLDSUN2 = 0,
  33. #endif
  34. #if defined (M_68010)
  35.   M__68010 = M_68010,
  36. #else
  37.   M_68010 = 1,
  38. #endif
  39. #if defined (M_68020)
  40.   M__68020 = M_68020,
  41. #else
  42.   M_68020 = 2,
  43. #endif
  44. #if defined (M_SPARC)
  45.   M__SPARC = M_SPARC,
  46. #else
  47.   M_SPARC = 3,
  48. #endif
  49.   /* skip a bunch so we don't run into any of sun's numbers */
  50.   M_386 = 100,
  51. };
  52.  
  53. #if !defined (N_MAGIC)
  54. #define N_MAGIC(exec) ((exec).a_info & 0xffff)
  55. #endif
  56. #define N_MACHTYPE(exec) ((enum machine_type)(((exec).a_info >> 16) & 0xff))
  57. #define N_FLAGS(exec) (((exec).a_info >> 24) & 0xff)
  58. #define N_SET_INFO(exec, magic, type, flags) \
  59.         ((exec).a_info = ((magic) & 0xffff) \
  60.          | (((int)(type) & 0xff) << 16) \
  61.          | (((flags) & 0xff) << 24))
  62. #define N_SET_MAGIC(exec, magic) \
  63.         ((exec).a_info = (((exec).a_info & 0xffff0000) | ((magic) & 0xffff)))
  64.  
  65. #define N_SET_MACHTYPE(exec, machtype) \
  66.         ((exec).a_info = \
  67.          ((exec).a_info&0xff00ffff) | ((((int)(machtype))&0xff) << 16))
  68.  
  69. #define N_SET_FLAGS(exec, flags) \
  70.         ((exec).a_info = \
  71.          ((exec).a_info&0x00ffffff) | (((flags) & 0xff) << 24))
  72.  
  73. /* Code indicating object file or impure executable.  */
  74. #define OMAGIC 0407
  75. /* Code indicating pure executable.  */
  76. #define NMAGIC 0410
  77. /* Code indicating demand-paged executable.  */
  78. #define ZMAGIC 0413
  79.  
  80. #if !defined (N_BADMAG)
  81. #define N_BADMAG(x)                                     \
  82.  (N_MAGIC(x) != OMAGIC && N_MAGIC(x) != NMAGIC          \
  83.   && N_MAGIC(x) != ZMAGIC)
  84. #endif
  85.  
  86. #define _N_BADMAG(x)                                    \
  87.  (N_MAGIC(x) != OMAGIC && N_MAGIC(x) != NMAGIC          \
  88.   && N_MAGIC(x) != ZMAGIC)
  89.  
  90. #define _N_HDROFF(x) 0
  91.  
  92. #if !defined (N_TXTOFF)
  93. #define N_TXTOFF(x) \
  94.  (N_MAGIC(x) == ZMAGIC ? _N_HDROFF((x)) + sizeof (struct exec) : sizeof (struct exec))
  95. #endif
  96.  
  97. #if !defined (N_DATOFF)
  98. #define N_DATOFF(x) (N_TXTOFF(x) + (x).a_text)
  99. #endif
  100.  
  101. #if !defined (N_TRELOFF)
  102. #define N_TRELOFF(x) (N_DATOFF(x) + (x).a_data)
  103. #endif
  104.  
  105. #if !defined (N_DRELOFF)
  106. #define N_DRELOFF(x) (N_TRELOFF(x) + (x).a_trsize)
  107. #endif
  108.  
  109. #if !defined (N_SYMOFF)
  110. #define N_SYMOFF(x) (N_DRELOFF(x) + (x).a_drsize)
  111. #endif
  112.  
  113. #if !defined (N_STROFF)
  114. #define N_STROFF(x) (N_SYMOFF(x) + (x).a_syms)
  115. #endif
  116.  
  117. /* Address of text segment in memory after it is loaded.  */
  118. #if !defined (N_TXTADDR)
  119. #define N_TXTADDR(x) (sizeof(struct exec)+4096)
  120. #endif
  121.  
  122. /* Address of data segment in memory after it is loaded.
  123.    Note that it is up to you to define SEGMENT_SIZE
  124.    on machines not listed here.  */
  125. #ifdef i386
  126. #define SEGMENT_SIZE 0x400000
  127. #endif
  128. #if defined(vax) || defined(hp300) || defined(pyr)
  129. #define SEGMENT_SIZE page_size
  130. #endif
  131. #ifdef  sony
  132. #define SEGMENT_SIZE    0x2000
  133. #endif  /* Sony.  */
  134. #ifdef is68k
  135. #define SEGMENT_SIZE 0x20000
  136. #endif
  137. #if defined(m68k) && defined(PORTAR)
  138. #define PAGE_SIZE 0x400
  139. #define SEGMENT_SIZE PAGE_SIZE
  140. #endif
  141.  
  142. #ifndef N_DATADDR
  143. #define N_DATADDR(x) \
  144.     (N_MAGIC(x)==OMAGIC? (N_TXTADDR(x)+(x).a_text) \
  145.      : (SEGMENT_SIZE + ((N_TXTADDR(x)+(x).a_text-1) & ~(SEGMENT_SIZE-1))))
  146. #endif
  147.  
  148. /* Address of bss segment in memory after it is loaded.  */
  149. #if !defined (N_BSSADDR)
  150. #define N_BSSADDR(x) (N_DATADDR(x) + (x).a_data)
  151. #endif
  152.  
  153. #if !defined (N_NLIST_DECLARED)
  154. struct nlist {
  155.   union {
  156.     char *n_name;
  157.     struct nlist *n_next;
  158.     long n_strx;
  159.   } n_un;
  160.   unsigned char n_type;
  161.   char n_other;
  162.   short n_desc;
  163.   unsigned long n_value;
  164. };
  165. #endif /* no N_NLIST_DECLARED.  */
  166.  
  167. #if !defined (N_UNDF)
  168. #define N_UNDF 0
  169. #endif
  170. #if !defined (N_ABS)
  171. #define N_ABS 2
  172. #endif
  173. #if !defined (N_TEXT)
  174. #define N_TEXT 4
  175. #endif
  176. #if !defined (N_DATA)
  177. #define N_DATA 6
  178. #endif
  179. #if !defined (N_BSS)
  180. #define N_BSS 8
  181. #endif
  182. #if !defined (N_FN)
  183. #define N_FN 15
  184. #endif
  185.  
  186. #if !defined (N_EXT)
  187. #define N_EXT 1
  188. #endif
  189. #if !defined (N_TYPE)
  190. #define N_TYPE 036
  191. #endif
  192. #if !defined (N_STAB)
  193. #define N_STAB 0340
  194. #endif
  195.  
  196. /* The following type indicates the definition of a symbol as being
  197.    an indirect reference to another symbol.  The other symbol
  198.    appears as an undefined reference, immediately following this symbol.
  199.  
  200.    Indirection is asymmetrical.  The other symbol's value will be used
  201.    to satisfy requests for the indirect symbol, but not vice versa.
  202.    If the other symbol does not have a definition, libraries will
  203.    be searched to find a definition.  */
  204. #define N_INDR 0xa
  205.  
  206. /* The following symbols refer to set elements.
  207.    All the N_SET[ATDB] symbols with the same name form one set.
  208.    Space is allocated for the set in the text section, and each set
  209.    element's value is stored into one word of the space.
  210.    The first word of the space is the length of the set (number of elements).
  211.  
  212.    The address of the set is made into an N_SETV symbol
  213.    whose name is the same as the name of the set.
  214.    This symbol acts like a N_DATA global symbol
  215.    in that it can satisfy undefined external references.  */
  216.  
  217. /* These appear as input to LD, in a .o file.  */
  218. #define N_SETA  0x14            /* Absolute set element symbol */
  219. #define N_SETT  0x16            /* Text set element symbol */
  220. #define N_SETD  0x18            /* Data set element symbol */
  221. #define N_SETB  0x1A            /* Bss set element symbol */
  222.  
  223. /* This is output from LD.  */
  224. #define N_SETV  0x1C            /* Pointer to set vector in data area.  */
  225.  
  226. #if !defined (N_RELOCATION_INFO_DECLARED)
  227. /* This structure describes a single relocation to be performed.
  228.    The text-relocation section of the file is a vector of these structures,
  229.    all of which apply to the text section.
  230.    Likewise, the data-relocation section applies to the data section.  */
  231.  
  232. struct relocation_info
  233. {
  234.   /* Address (within segment) to be relocated.  */
  235.   int r_address;
  236.   /* The meaning of r_symbolnum depends on r_extern.  */
  237.   unsigned int r_symbolnum:24;
  238.   /* Nonzero means value is a pc-relative offset
  239.      and it should be relocated for changes in its own address
  240.      as well as for changes in the symbol or section specified.  */
  241.   unsigned int r_pcrel:1;
  242.   /* Length (as exponent of 2) of the field to be relocated.
  243.      Thus, a value of 2 indicates 1<<2 bytes.  */
  244.   unsigned int r_length:2;
  245.   /* 1 => relocate with value of symbol.
  246.           r_symbolnum is the index of the symbol
  247.           in file's the symbol table.
  248.      0 => relocate with the address of a segment.
  249.           r_symbolnum is N_TEXT, N_DATA, N_BSS or N_ABS
  250.           (the N_EXT bit may be set also, but signifies nothing).  */
  251.   unsigned int r_extern:1;
  252.   /* Four bits that aren't used, but when writing an object file
  253.      it is desirable to clear them.  */
  254.   unsigned int r_pad:4;
  255. };
  256. #endif /* no N_RELOCATION_INFO_DECLARED.  */
  257.  
  258.  
  259. #endif /* __A_OUT_GNU_H__ */
  260.